package com.ars.common.servlet.admin.activity;

import com.ars.common.beans.Active.Active;
import com.ars.common.beans.User.User;
import com.ars.common.dao.activity.FindActivityById;
import com.ars.common.servlet.Userservlet.GetUser;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

/**
 * ClassName: UpdateActivityDispatcher
 * Package: com.ars.common.servlet.admin.activity
 * Description:
 *
 * @Author: Bryan Long
 * @Create: 2024/7/29 - 15:31
 * @Version: v1.0
 */

@WebServlet("/UpdateActivityDispatcher")
public class UpdateActivityDispatcher extends HttpServlet {
    private static final long serialVersionUID = 1L;
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // refers to editUser.java

        String id = request.getParameter("id");
        Active activity=new Active();

        System.out.println("editActivityId: "+id);

        try
        {
            activity = new FindActivityById().findActivityById(id);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

        request.setAttribute("activity", activity);
        request.getRequestDispatcher("/admin/editactivity.jsp").forward(request, response);
    }
}
